Unlock Projects

I'm trying to create an Archiving tool that will archive a specified project to a specific folder.  However, when in the testing phase, it became obvious that I was going to run into a problem when attempting to archive the projects.  I am getting a warning box that says

"Invalid lock request - data already locked

Failed to lock archive item (/Test Project A) for inclusion in archive"

Is there any way to get around this?  I'm thinking there must be a way to unlock modules as a whole, if that's what I need to do.  However, in all of my searching through the DXL Reference manual and online, I have only been able to find the method which locks modules, not projects.

So i guess I'm looking for a method which for a current project which is called "p", will "unlock" p so that I can archive it.

Thanks!

Josiah


josiah820 - Wed May 22 09:42:52 EDT 2013

Re: Unlock Projects
Tony_Goodman - Wed May 22 10:35:49 EDT 2013

 

Something like this should do the trick...

 

Project p = null
LockList lcks = null
Lock lck = null

// get a handle on your project, then ..

lcks = getLocksInFolder(p, true, true)

 

for lck in lcks do
{

    remove(lck)

}

 

 

Re: Unlock Projects
josiah820 - Wed May 22 10:57:37 EDT 2013

Tony_Goodman - Wed May 22 10:35:49 EDT 2013

 

Something like this should do the trick...

 

Project p = null
LockList lcks = null
Lock lck = null

// get a handle on your project, then ..

lcks = getLocksInFolder(p, true, true)

 

for lck in lcks do
{

    remove(lck)

}

 

 

So I should just let p be a null variable, and then declare it as "current" after that code and before I call the archive function?

Re: Unlock Projects
josiah820 - Wed May 22 11:02:59 EDT 2013

Tony_Goodman - Wed May 22 10:35:49 EDT 2013

 

Something like this should do the trick...

 

Project p = null
LockList lcks = null
Lock lck = null

// get a handle on your project, then ..

lcks = getLocksInFolder(p, true, true)

 

for lck in lcks do
{

    remove(lck)

}

 

 

Actually, never mind.  With that code in my program, only declaring:

project p = current

so that there isn't a null project passed on to the getLocksInFolder method, I'm still getting the same error.  Do you have any other ideas?

Re: Unlock Projects
Tony_Goodman - Wed May 22 11:10:07 EDT 2013

josiah820 - Wed May 22 11:02:59 EDT 2013

Actually, never mind.  With that code in my program, only declaring:

project p = current

so that there isn't a null project passed on to the getLocksInFolder method, I'm still getting the same error.  Do you have any other ideas?

No.

You need to assign the project variable before you use it, e.g.

p = project("name of your project")

Do not use current, as by definition if a project is current then you have it open (locked).

 

Re: Unlock Projects
josiah820 - Wed May 22 11:31:47 EDT 2013

Tony_Goodman - Wed May 22 11:10:07 EDT 2013

No.

You need to assign the project variable before you use it, e.g.

p = project("name of your project")

Do not use current, as by definition if a project is current then you have it open (locked).

 

Oh yeah! I forgot about the whole current must be open thing.  I only have one problem now.  In the "getLocksInFolder" method, I am getting a null Folder parameter was passed alert for the project p.  I am taking the value (the project name) that I got from a radio button list Dialog Box Element, putting it into a string which is called "selection" and then putting:

p = project(selection)

but this is causing a problem.  Any suggestions about how to go about fixing this?

Thanks for your help.

Re: Unlock Projects
llandale - Wed May 22 14:23:21 EDT 2013

As Tony said if the Project in question is "current" then YOU have it open (and it appears in the LEFT pane of the Explorer) and it is locked.  No, select the database folder (in database view) when archiving projects.

I think you need to put a slash on the name of the project

  • Project p = project("/" selection)

It may be better to be nice and ASK these folks to close their modules and exit DOORS.  Or,, schedule it to run at night.

-Louie

Re: Unlock Projects
josiah820 - Wed May 22 15:03:16 EDT 2013

llandale - Wed May 22 14:23:21 EDT 2013

As Tony said if the Project in question is "current" then YOU have it open (and it appears in the LEFT pane of the Explorer) and it is locked.  No, select the database folder (in database view) when archiving projects.

I think you need to put a slash on the name of the project

  • Project p = project("/" selection)

It may be better to be nice and ASK these folks to close their modules and exit DOORS.  Or,, schedule it to run at night.

-Louie

Is it possible to "schedule" a process?

Re: Unlock Projects
llandale - Thu May 23 12:47:56 EDT 2013

josiah820 - Wed May 22 15:03:16 EDT 2013

Is it possible to "schedule" a process?

I've been doing it with Windows Scheduled Tasks.  I schedule a *.bat file that logs into DOORs and runs the batch-mode friendly script.

On-demand you could display a dialog and ask how long you want to wait; maybe 5 hours 30 minutes; convert that to milli-seconds and then issue the "sleep_(int)" command.

-Louie

Re: Unlock Projects
josiah820 - Thu May 23 13:43:25 EDT 2013

llandale - Thu May 23 12:47:56 EDT 2013

I've been doing it with Windows Scheduled Tasks.  I schedule a *.bat file that logs into DOORs and runs the batch-mode friendly script.

On-demand you could display a dialog and ask how long you want to wait; maybe 5 hours 30 minutes; convert that to milli-seconds and then issue the "sleep_(int)" command.

-Louie

Oh wow, okay.  I didn't even know that DOORS and DXL worked with batch processing.  Not sure how I missed that!

Re: Unlock Projects
llandale - Thu May 23 16:27:44 EDT 2013

josiah820 - Thu May 23 13:43:25 EDT 2013

Oh wow, okay.  I didn't even know that DOORS and DXL worked with batch processing.  Not sure how I missed that!

There is no GUI functions loaded in batch-mode, so batch scripts cannot do things like display dialogs or even "ack".

Here is an example of a batch file.

"c:\Program Files\IBM\Rational\DOORS\9.3\bin\doors.exe" -u Administrator -P "ThePassword" -b "I:\DXL-InProgress\Menu-Explorer\Explorer-Scripts\Explorer-General\DB-Admins\BatchScripts\Formals_EditSave-Batch.dxl"

That command line can indeed go directly into the scheduled task (using no *.bat file), but I put it in a *.bat file in a folder that lacks any "R"ead access to anybody but myself ; in an attempt to protect the DOORS Administrator's password.  <-- clever folks who want to comment on that will please PM me instead of posting.  Seems to me I had some debugging advantage using the batch file, but I don't recall now. 

Certainly get the code to work on-demand before trying it batch.  Also, there exists a command that may help DXL run both in batch and on-demand:

  • batchMode()
  • e.g.   if (!batchMode()) ack(Error)

-Louie

Re: Unlock Projects
josiah820 - Fri May 24 13:24:33 EDT 2013

llandale - Thu May 23 16:27:44 EDT 2013

There is no GUI functions loaded in batch-mode, so batch scripts cannot do things like display dialogs or even "ack".

Here is an example of a batch file.

"c:\Program Files\IBM\Rational\DOORS\9.3\bin\doors.exe" -u Administrator -P "ThePassword" -b "I:\DXL-InProgress\Menu-Explorer\Explorer-Scripts\Explorer-General\DB-Admins\BatchScripts\Formals_EditSave-Batch.dxl"

That command line can indeed go directly into the scheduled task (using no *.bat file), but I put it in a *.bat file in a folder that lacks any "R"ead access to anybody but myself ; in an attempt to protect the DOORS Administrator's password.  <-- clever folks who want to comment on that will please PM me instead of posting.  Seems to me I had some debugging advantage using the batch file, but I don't recall now. 

Certainly get the code to work on-demand before trying it batch.  Also, there exists a command that may help DXL run both in batch and on-demand:

  • batchMode()
  • e.g.   if (!batchMode()) ack(Error)

-Louie

Okay, that makes sense.  I don't think it would do me any good for this program, but that's a good thing to know! Thanks!

Re: Unlock Projects
ChrisAnnal - Thu Aug 01 09:56:06 EDT 2013

josiah820 - Fri May 24 13:24:33 EDT 2013

Okay, that makes sense.  I don't think it would do me any good for this program, but that's a good thing to know! Thanks!

It may be dangerous to simply unlock a project. I wrote a script for running a batch process that sends me an email when all the projects have been archived (to a folder on my local "C" drive) and includes details about who has a lock on the projects that were skipped - so I can in turn email or call those users and alert them that I'm trying to archive that project. Maybe some of the following might be useful to you. I have a special "DOORS" account set up with my CTS department so that emails can be sent from it. Anyway, here's how the current script looks. The stuff in brackets would be replaced by your particular email setup...

There is a break in the line of code that begins "string proj_archive = archive (sProjectName,"c:\\DOORS_Projects"

That should all be on line, together with "\\"(sProjectName)".dpa",false,true,allBaselines,false)" below it.

 

 

//Archive Projects - CheckLocks
/*
Archive projects, after first checking to make sure they aren't locked - email results
*/

//Created 09/07/2011 - Saab Sensis Corp - C. Annal
/*******************************************************************************
 * Global constants
 */
              
const     string    targetAddress = "<your email address>"
const     string     emailServer = "<your company's email server>"
const     string     emailAccount = "<set up an account for DOORS emails and use it here>"
const    string     fromDescription = "DOORS"
const    string     subject = "Archive Results"

/*******************************************************************************
 * Global Variables
 */
Lock lockItem
LockList lcklist
string sProjectName
string message     = ""
Project pX
Buffer bx1=create, bx2=create

/*******************************************************************************
 * Function Declarations
 */
bool bLockedByAnyUser=true, bLocked

/*******************************************************************************
 * Script
 */

for pX in database do {  
sProjectName = name pX   
Project parent = getParentProject(pX)
if(null parent && !isDeleted pX){
   lcklist = getLocksInFolder(pX,true,bLockedByAnyUser)
   bLocked=false
for lockItem in lcklist do {
   bLocked=true;
   string lckuser = lockItem.user
   bx1+=sProjectName " locked by " lckuser "\n";
   break
}// End for lockItem in lcklist do
   if(bLocked)continue
   bx2+= sProjectName " was processed \n"
   string proj_archive = archive (sProjectName,"c:\\DOORS_Projects\\"(sProjectName)".dpa",false,true,allBaselines,false)    
if (!null proj_archive)
    {
        ack proj_archive
        halt
    }// End !null proj_archive
}// End if(null parent && !isDeleted pX)
}// End for pX in database do
message = bx1 "\n" bx2""
sendEMailNotification(
    fromDescription,
    targetAddress,
    subject,
    message)
//halt